//
//  SecondViewController.m
//  UI08_界面传值
//
//  Created by wyx on 16/3/18.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "SecondViewController.h"
#import "ViewController.h"

@interface SecondViewController ()
@property (nonatomic, retain) UIButton *button;
@property (nonatomic, retain) UILabel *lableOfUser;
@property (nonatomic, retain) UITextField *text;
@end

@implementation SecondViewController
//-(void)dealloc{
//    [_content release];
//    [_button release];
//    [_lableOfUser release];
//    [super dealloc];
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createButton];
    [self createLable];
    [self configForNavigationItem];
    [self createTextFiled];
}
#pragma mark -Button
-(void)createButton {
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    self.button.frame = CGRectMake(50, 80, 200, 40);
    [self.button setTitle:@"Back" forState:UIControlStateNormal];
    self.button.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:self.button];
    [self.button release];
    [self.button addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)backAction:(UIButton *)button {
    //执行协议方法
    [self.secondDeledate changeValue:self.text.text];
    [self.navigationController popViewControllerAnimated:YES];
    self.navigationController.navigationBarHidden = NO;
    
}
- (void)createLable{
    self.lableOfUser = [[UILabel alloc] initWithFrame:CGRectMake(50, 200, 200, 50)];
    self.lableOfUser.backgroundColor = [UIColor yellowColor];
    //赋值
    self.lableOfUser.text = self.content;
    [self.view addSubview:self.lableOfUser];
    [_lableOfUser release];
}
- (void)createTextFiled{
    self.text = [[UITextField alloc] initWithFrame:CGRectMake(50, 300, 200, 50)];
    self.text.placeholder = @"打的字在第一界面显示";
    self.text.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:self.text];
    [_text release];
}

- (void)configForNavigationItem{
    //中间title
    self.navigationItem.title = @"第二页";
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
